<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</head>
<body>
    <h1>axios练习</h1>
  <form id="form">
    <input id="iptname" type="text" name="name">
    <input id="iptage" type="text" name="age">
    <button id="postBtn">post请求</button>
    <button id="cacel">取消请求</button>
  </form>
  <script>
    const userN = document.querySelector('iptname')
    const ageA = document.querySelector('iptage')
    const postBtn = document.querySelector('#postBtn')
    const caCelAsk = document.querySelector('#cacel')
    const oForm  = document.querySelector('#form')

    // 设置一个axios实例  并且做一个全局配置
    // const myAxios = axios.create({
    //   baseURL:'http://127.0.0.1:3333' , //配置路径
    //   timeout: 10000  ,         //配置超时状态
    //   headers:{}
    // })

    // 给form表单绑定事件
    oForm.onsubmit =async function(){

      await axios.post('/post',{
        
      })



      return false // 取消表单的自动提交
    }
  </script>
</body>
</html>